Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

534
Vistas
when calling $emit: [Vue warn]: Error in v-on handler: "TypeError: Object(...) is not a function" Vue 2

Everything worked perfectly fine until all of a sudden it didn't anymore.

I have a button with a on-click event. When I click on it, it calls the method giveToParent() which emits a string:

<template>
  <div>
    <button @click="giveToParent()">search</button>
  </div>
</template>

<script>
export default {
...
  methods: {
    giveToParent() {
      var sql = "select * from xxxxx where min_Price=20";

      this.$emit("clicked", sql);


      console.log(this.$emit("clicked", sql));
    },

In the parent (app.vue) it looks like this:

<template>
  <Menu_Filter @clicked="test()"></Menu_Filter>
</template>

<script>
import Menu_Filter from "./components/Menu_Filter";
import { loadMap } from "./packs/my_js_file.js";

export default {
...
  },
  methods: {
    test(value) {
      logInConsole(value);
      loadMap(value);
    },
    
  },
};

The error message is the following: error As you can see, it says object is not a function, which is true, because the $emit function seems to be a vue component. I can log something else with no problem, so it has to be the $emit function.

The weird thing is that it all worked and suddenly it didn't anymore. I even had an older version of this on my laptop and when I tried to execute it there, it failed as well.

I seriously don't know why is doesn't work anymore.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

<template>
  <div>
    <button @click="giveToParent">search</button>
  </div>
</template>

This should do the trick, v-on does not like calling it as a function without arguments.

about 4 years ago · Juan Pablo Isaza Denunciar

0

can you test with click.native? I'm not sure but I opine you can solve it with this trick

<div id="app">
    <Menu_Filter v-on:click.native="testFunction"></Menu_Filter>
</div>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda